package com.herench.bunch.exam.handler;

import com.herench.bunch.commons.annotation.Handler;
import com.herench.bunch.commons.support.AbstractMessageHandler;
import com.herench.bunch.exam.agent.ExamOperationAgent;
import com.herench.bunch.exam.convert.ExamReportConvert;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

/**
 * @author luoxiaoming on 18-9-17 下午5:11
 * @email luoxiaoming@herench.com
 */

@Handler(code = "900030",name = "检查报告返回",messageConvertClass = ExamReportConvert.class)
public class ExamReportHandler extends AbstractMessageHandler {

    @Autowired
    private ExamOperationAgent examOperationAgent;

    @Override
    protected Object proxyInvoke(Object inMessage) throws Exception {
        Map<String,Object> params = (Map<String, Object>) inMessage;
        if (params.get("actionType").equals("update")) {
            examOperationAgent.modify(params);
        }
        if (params.get("ret").equals("0")){
            params.put("applyId",params.get("").toString().substring(2));
            examOperationAgent.delete(params);
        }
        return params;
    }
}
